/* SPDX-License-Identifier: Apache-2.0 OR MIT */
/*
 * Copyright (c) 2017 Rockchip Electronics Co., Ltd.
 */

#include "hal_vp8e_table.h"

RK_S32 const default_prob_coeff_tbl[4][8][3][11] = {
    {
        {
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
        },
        {
            {253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128},
            {189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128},
            {106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128}
        },
        {
            {  1,  98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
            {181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128},
            { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 }
        },
        {
            {  1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
            {184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128},
            { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 }
        },
        {
            {  1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
            {170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128},
            { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 }
        },
        {
            {  1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
            {207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128},
            {102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128}
        },
        {
            {  1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
            {177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128},
            { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 }
        },
        {
            {  1,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
            {246,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
            {255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
        }
    },
    {
        {
            {198,  35, 237, 223, 193, 187, 162, 160, 145, 155,  62},
            {131,  45, 198, 221, 172, 176, 220, 157, 252, 221,   1},
            { 68,  47, 146, 208, 149, 167, 221, 162, 255, 223, 128 }
        },
        {
            {  1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
            {184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128},
            { 81,  99, 181, 242, 176, 190, 249, 202, 255, 255, 128 }
        },
        {
            {  1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
            { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
            { 23,  91, 163, 242, 170, 187, 247, 210, 255, 255, 128 }
        },
        {
            {  1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
            {109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128},
            { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 }
        },
        {
            {  1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
            { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
            { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 }
        },
        {
            {  1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
            {124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128},
            { 35,  77, 181, 251, 193, 211, 255, 205, 128, 128, 128 }
        },
        {
            {  1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
            {121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128},
            { 45,  99, 188, 251, 195, 217, 255, 224, 128, 128, 128 }
        },
        {
            {  1,   1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
            {203,   1, 248, 255, 255, 128, 128, 128, 128, 128, 128},
            {137,   1, 177, 255, 224, 255, 128, 128, 128, 128, 128}
        }
    },
    {
        {
            {253,   9, 248, 251, 207, 208, 255, 192, 128, 128, 128},
            {175,  13, 224, 243, 193, 185, 249, 198, 255, 255, 128},
            { 73,  17, 171, 221, 161, 179, 236, 167, 255, 234, 128 }
        },
        {
            {  1,  95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
            {239,  90, 244, 250, 211, 209, 255, 255, 128, 128, 128},
            {155,  77, 195, 248, 188, 195, 255, 255, 128, 128, 128}
        },
        {
            {  1,  24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
            {201,  51, 219, 255, 196, 186, 128, 128, 128, 128, 128},
            { 69,  46, 190, 239, 201, 218, 255, 228, 128, 128, 128 }
        },
        {
            {  1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
            {223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128},
            {141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128}
        },
        {
            {  1,  16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
            {190,  36, 230, 255, 236, 255, 128, 128, 128, 128, 128},
            {149,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128}
        },
        {
            {  1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
            {247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128},
            {240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128}
        },
        {
            {  1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
            {213,  62, 250, 255, 255, 128, 128, 128, 128, 128, 128},
            { 55,  93, 255, 128, 128, 128, 128, 128, 128, 128, 128 }
        },
        {
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
            {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}
        }
    },
    {
        {
            {202,  24, 213, 235, 186, 191, 220, 160, 240, 175, 255},
            {126,  38, 182, 232, 169, 184, 228, 174, 255, 187, 128},
            { 61,  46, 138, 219, 151, 178, 240, 170, 255, 216, 128 }
        },
        {
            {  1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
            {166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128},
            { 39,  77, 162, 232, 172, 180, 245, 178, 255, 255, 128 }
        },
        {
            {  1,  52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
            {124,  74, 191, 243, 183, 193, 250, 221, 255, 255, 128},
            { 24,  71, 130, 219, 154, 170, 243, 182, 255, 255, 128 }
        },
        {
            {  1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
            {149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128},
            { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 }
        },
        {
            {  1,  81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
            {123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128},
            { 20,  95, 153, 243, 164, 173, 255, 203, 128, 128, 128 }
        },
        {
            {  1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
            {168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128},
            { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 }
        },
        {
            {  1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
            {141,  84, 213, 252, 201, 202, 255, 219, 128, 128, 128},
            { 42,  80, 160, 240, 162, 185, 255, 205, 128, 128, 128 }
        },
        {
            {  1,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
            {244,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128},
            {238,   1, 255, 128, 128, 128, 128, 128, 128, 128, 128}
        }
    }
};

RK_S32 const default_prob_mv_tbl[2][19] = {
    {
        162, 128, 225, 146, 172, 147, 214,  39, 156, 128,
        129, 132,  75, 145, 178, 206, 239, 254, 254
    },

    {
        164, 128, 204, 170, 119, 235, 140, 230, 228, 128,
        130, 130,  74, 148, 180, 203, 236, 254, 254
    }
};

RK_S32 const vp8_prob_cost_tbl[] = {
    2048, 2048, 1792, 1642, 1536, 1454, 1386, 1329, 1280, 1236,
    1198, 1162, 1130, 1101, 1073, 1048, 1024, 1002,  980,  961,
    942,  924,  906,  890,  874,  859,  845,  831,  817,  804,
    792,  780,  768,  757,  746,  735,  724,  714,  705,  695,
    686,  676,  668,  659,  650,  642,  634,  626,  618,  611,
    603,  596,  589,  582,  575,  568,  561,  555,  548,  542,
    536,  530,  524,  518,  512,  506,  501,  495,  490,  484,
    479,  474,  468,  463,  458,  453,  449,  444,  439,  434,
    430,  425,  420,  416,  412,  407,  403,  399,  394,  390,
    386,  382,  378,  374,  370,  366,  362,  358,  355,  351,
    347,  343,  340,  336,  333,  329,  326,  322,  319,  315,
    312,  309,  305,  302,  299,  296,  292,  289,  286,  283,
    280,  277,  274,  271,  268,  265,  262,  259,  256,  253,
    250,  247,  245,  242,  239,  236,  234,  231,  228,  226,
    223,  220,  218,  215,  212,  210,  207,  205,  202,  200,
    197,  195,  193,  190,  188,  185,  183,  181,  178,  176,
    174,  171,  169,  167,  164,  162,  160,  158,  156,  153,
    151,  149,  147,  145,  143,  140,  138,  136,  134,  132,
    130,  128,  126,  124,  122,  120,  118,  116,  114,  112,
    110,  108,  106,  104,  102,  101,   99,   97,   95,   93,
    91,   89,   87,   86,   84,   82,   80,   78,   77,   75,
    73,   71,   70,   68,   66,   64,   63,   61,   59,   58,
    56,   54,   53,   51,   49,   48,   46,   44,   43,   41,
    40,   38,   36,   35,   33,   32,   30,   28,   27,   25,
    24,   22,   21,   19,   18,   16,   15,   13,   12,   10,
    9,    7,    6,    4,    3,    1
};

RK_S32 const coeff_update_prob_tbl[4][8][3][11] = {
    {
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255},
            {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255},
            {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255},
            {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255},
            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        }
    },
    {
        {
            {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255},
            {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255}
        },
        {
            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        }
    },

    {
        {
            {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255},
            {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255},
            {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255}
        },
        {
            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        }
    },

    {
        {
            {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255},
            {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255},
            {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255},
            {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        },
        {
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
        }
    }
};

RK_S32 const mv_update_prob_tbl[2][19] = {
    {
        237, 246, 253, 253, 254, 254, 254, 254, 254, 254,
        254, 254, 254, 254, 250, 250, 252, 254, 254
    },
    {
        231, 243, 245, 253, 254, 254, 254, 254, 254, 254,
        254, 254, 254, 254, 251, 251, 254, 254, 254
    }
};

RK_S32 const default_skip_false_prob_tbl[128] = {
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    251, 248, 244, 240, 236, 232, 229, 225,
    221, 217, 213, 208, 204, 199, 194, 190,
    187, 183, 179, 175, 172, 168, 164, 160,
    157, 153, 149, 145, 142, 138, 134, 130,
    127, 124, 120, 117, 114, 110, 107, 104,
    101, 98,  95,  92,  89,  86,  83, 80,
    77,  74,  71,  68,  65,  62,  59, 56,
    53,  50,  47,  44,  41,  38,  35, 32,
    30,  28,  26,  24,  22,  20,  18, 16,
};

RK_S32 const y_mode_prob_tbl[4] = {
    112, 86, 140, 37
};

RK_S32 const uv_mode_prob_tbl[3] = {
    162, 101, 204
};

Vp8eTree const mv_tree_tbl[] = {
    {0, 3, {0, 1, 2}},      /* mv_0 000 */
    {1, 3, {0, 1, 2}},      /* mv_1 001 */
    {2, 3, {0, 1, 3}},      /* mv_2 010 */
    {3, 3, {0, 1, 3}},      /* mv_3 011 */
    {4, 3, {0, 4, 5}},      /* mv_4 100 */
    {5, 3, {0, 4, 5}},      /* mv_5 101 */
    {6, 3, {0, 4, 6}},      /* mv_6 110 */
    {7, 3, {0, 4, 6}},      /* mv_7 111 */
};

RK_S32 const dc_q_lookup_tbl[QINDEX_RANGE] = {
    4,   5,   6,   7,   8,   9,   10,  10,  11,  12,
    13,  14,  15,  16,  17,  17,  18,  19,  20,  20,
    21,  21,  22,  22,  23,  23,  24,  25,  25,  26,
    27,  28,  29,  30,  31,  32,  33,  34,  35,  36,
    37,  37,  38,  39,  40,  41,  42,  43,  44,  45,
    46,  46,  47,  48,  49,  50,  51,  52,  53,  54,
    55,  56,  57,  58,  59,  60,  61,  62,  63,  64,
    65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
    75,  76,  76,  77,  78,  79,  80,  81,  82,  83,
    84,  85,  86,  87,  88,  89,  91,  93,  95,  96,
    98,  100, 101, 102, 104, 106, 108, 110, 112, 114,
    116, 118, 122, 124, 126, 128, 130, 132, 134, 136,
    138, 140, 143, 145, 148, 151, 154, 157
};

RK_S32 const ac_q_lookup_tbl[QINDEX_RANGE] = {
    4,   5,   6,   7,   8,   9,   10,  11,  12,  13,
    14,  15,  16,  17,  18,  19,  20,  21,  22,  23,
    24,  25,  26,  27,  28,  29,  30,  31,  32,  33,
    34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
    44,  45,  46,  47,  48,  49,  50,  51,  52,  53,
    54,  55,  56,  57,  58,  60,  62,  64,  66,  68,
    70,  72,  74,  76,  78,  80,  82,  84,  86,  88,
    90,  92,  94,  96,  98,  100, 102, 104, 106, 108,
    110, 112, 114, 116, 119, 122, 125, 128, 131, 134,
    137, 140, 143, 146, 149, 152, 155, 158, 161, 164,
    167, 170, 173, 177, 181, 185, 189, 193, 197, 201,
    205, 209, 213, 217, 221, 225, 229, 234, 239, 245,
    249, 254, 259, 264, 269, 274, 279, 284
};

RK_S32 const q_rounding_factors_tbl[QINDEX_RANGE] = {
    56, 56, 56, 56, 56, 56, 56, 56, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
    48, 48, 48, 48, 48, 48, 48, 48
};

RK_S32 const q_zbin_factors_tbl[QINDEX_RANGE] = {
    64, 64, 64, 64, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
    80, 80, 80, 80, 80, 80, 80, 80
};

RK_S32 const zbin_boost_tbl[16] = {
    0,   0,  8, 10, 12, 14, 16, 20, 24, 28,
    32, 36, 40, 44, 44, 44
};

RK_S32 const vp8_split_penalty_tbl[128] = {
    24, 25, 26, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 36,
    37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 52, 53, 54,
    56, 57, 59, 60, 62, 63, 65, 67, 68, 70, 72, 74, 76, 78, 80, 82,
    84, 86, 88, 91, 93, 95, 98, 100, 103, 106, 108, 111, 114, 117, 120, 123,
    126, 130, 133, 136, 140, 144, 147, 151, 155, 159, 163, 167, 172, 176, 181, 185,
    190, 195, 200, 205, 211, 216, 222, 227, 233, 239, 245, 252, 258, 265, 272, 279,
    286, 293, 301, 309, 317, 325, 333, 342, 351, 360, 369, 379, 388, 398, 409, 419,
    430, 441, 453, 464, 476, 488, 501, 514, 527, 541, 555, 569, 584, 599, 614, 630
};

RK_S32 const weight_tbl[128] = {
    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
    4,  4,  4,  4,  4,  5,  5,  5,  5,  5,
    5,  5,  5,  5,  5,  5,  5,  6,  6,  6,
    6,  6,  6,  6,  6,  6,  6,  7,  7,  7,
    7,  7,  7,  7,  7,  8,  8,  8,  8,  8,
    8,  8,  9,  9,  9,  9,  9, 10, 10, 10,
    10, 11, 11, 11, 12, 12, 13, 13, 13, 13,
    14, 14, 14, 14, 15, 15, 15, 16, 16, 17,
    17, 18, 18, 19, 19, 20, 20, 20, 21, 22,
    23, 23, 24, 24, 25, 25, 26, 27, 28, 28,
    29, 30, 31, 32, 32, 33, 34, 35, 36, 37,
    38, 39, 40, 41, 42, 44, 44, 46, 47, 48,
    50, 51, 52, 54, 55, 57, 58, 61
};

RK_S32 const intra4_mode_tree_penalty_tbl[] = {
    280, 622, 832, 1177, 1240, 1341, 1085, 1259, 1357, 1495
};

RK_S32 const intra16_mode_tree_penalty_tbl[] = {
    305, 841, 914, 1082
};

RK_S32 const inter_level_tbl[128] = {
    8,  8,  8,  9,  9,  9,  9,  9,  9,  9,
    9,  9,  9,  9,  9,  9, 10, 10, 10, 10,
    10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
    11, 11, 12, 12, 12, 12, 12, 12, 13, 13,
    13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
    15, 16, 16, 16, 16, 17, 17, 17, 18, 18,
    18, 19, 19, 20, 20, 20, 21, 21, 22, 22,
    23, 23, 24, 24, 25, 25, 26, 26, 27, 28,
    28, 29, 30, 30, 31, 32, 33, 33, 34, 35,
    36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
    46, 48, 49, 50, 51, 53, 54, 56, 57, 59,
    60, 62, 63, 63, 63, 63, 63, 63, 63, 63,
    63, 63, 63, 63, 63, 63, 63, 63
};

RK_S32 const offset_tbl[] = {
    -1, -1, -1,  0,  1,  2, -1,  3,  4, -1,  5,  6, -1,  7,  8, -1,
    9, 10, -1, 11, 12, 13, 14, 15, -1, 16, 17, -1, 18, 19, -1, 20,
    21, -1, 22, 23, -1, 24, 25, -1, 26, 27, 28, 29, 30, -1, 31, 32,
    -1, 33, 34, -1, 35, 36, -1, 37, 38, -1, 39, 40, -1, 41, 42, 43,
    44, 45, -1, 46, 47, -1, 48, 49, -1, 50, 51, -1, 52, 53, -1, 54,
    55, -1, 56, 57, -1, -1, -1, 58, 59, 60, 61, 62, 63, 64, 65, 66,
    67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
    83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
    99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
    115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
    131, 132, 133, 134, 135, 136, 137, 138, -1, -1, -1, 139, 140, 141, 142, 143,
    144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
    160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
    176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
    192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
    208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219
};
